const BASE_URL='http://192.168.10.134:9000'
export const myRequest = (options) =>{
	return new Promise((resolve,reject)=>{
		uni.request({
			url:BASE_URL+options.url,
			method:options.method || 'GET',
			data:options.data || {},
			header:options.header|| {},
			
			success:(res)=>{
				
				resolve(res)
			},
			fail:(err)=>{
				 uni.showToast({
				title:'请求接口失败'
				})
				reject(err)
			}
		})
	})
}

export const mydateformat = () =>{
		//获取当前时间的后一个小时
        let date = new Date(new Date().getTime()+3600000),
        currentDate,
        currentTime,
        seperator = "-", // 如果想要其他格式 只需 修改这里 
        year = date.getFullYear(),
        month = date.getMonth() + 1,
        weex = date.getDay(),
        day = date.getDate(),
        hour = date.getHours() < 10 ? "0" + date.getHours() : date.getHours(),
        minute = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes(),
        second = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
        month >= 1 && month <= 9 ? (month = "0" + month) : "";
        day >= 0 && day <= 9 ? (day = "0" + day) : "";
          //当前 日期
         currentDate = year + seperator + month + seperator + day;
          //当前 时间
         currentTime = hour + ":" + minute ;
		 return currentTime;
          // 输出格式 为 2018-8-27 14:45:33
         // console.log(currentDate +" "+ currentTime);
        
        /* if(type==0){
             return currentDate
         }
         else if(type==1){
             return currentTime;
         }
         else if(type==2){
             if(weex==1){
                 return '星期一'
             }if(weex==2){
                 return '星期二'
             }if(weex==3){
                 return '星期三'
             }if(weex==4){
                 return '星期四'
             }if(weex==5){
                 return '星期五'
             }if(weex==6){
                 return '星期六'
             }if(weex==7){
                 return '星期日'
             }
         }
         else{
            return currentDate+" "+ currentTime;
         } */
}
//截取时间，不要秒数,传过来的是Date
export const mydateformatSub = (date) =>{
		let seperator = "-", // 如果想要其他格式 只需 修改这里 
        year = date.getFullYear(),
        month = date.getMonth() + 1,
        weex = date.getDay(),
        day = date.getDate(),
        hour = date.getHours() < 10 ? "0" + date.getHours() : date.getHours(),
        minute = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes(),
        second = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
        month >= 1 && month <= 9 ? (month = "0" + month) : "";
        day >= 0 && day <= 9 ? (day = "0" + day) : "";
          //当前 日期
        let currentDate = year + seperator + month + seperator + day;
          //当前 时间
        let currentTime = hour + ":" + minute ;
		 return currentDate+" "+currentTime;
          // 输出格式 为 2018-8-27 14:45:33
         // console.log(currentDate +" "+ currentTime);
        
        /* if(type==0){
             return currentDate
         }
         else if(type==1){
             return currentTime;
         }
         else if(type==2){
             if(weex==1){
                 return '星期一'
             }if(weex==2){
                 return '星期二'
             }if(weex==3){
                 return '星期三'
             }if(weex==4){
                 return '星期四'
             }if(weex==5){
                 return '星期五'
             }if(weex==6){
                 return '星期六'
             }if(weex==7){
                 return '星期日'
             }
         }
         else{
            return currentDate+" "+ currentTime;
         } */
}